package com.juyu.miliao.api.service;

import javax.annotation.Resource;

import com.juyu.miliao.api.util.SystemMessageUtil;
import org.springframework.stereotype.Service;

import com.juyu.miliao.api.dao.mysql.OpinionDao;
import com.juyu.miliao.api.domain.Opinion;
import com.juyu.miliao.common.exception.IllegalParamException;

@Service
public class OpinionService {
	@Resource
	private OpinionDao opinionDao;
	@Resource
	private SystemMessageUtil systemMessageUtil;

	//TODO 不能存，分割
	public void insertOpinion(Opinion entity) {
		//目前最大上传4张
		if(entity.getPicUrl()!=null && !entity.getPicUrl().equals("") &&!entity.getPicUrl().equals("null")){
			if(entity.getPicUrl().contains(",")){
				String [] array = entity.getPicUrl().split(",");
				if(array.length>4)
					throw new IllegalParamException("上传图片超过最大值4");
			}
		}
		int i = opinionDao.insertOpinion(entity);
//		if(i>0){
//			systemMessageUtil.userFeedBack(entity.getUserId());
//		}
	}
	
}
